﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Math;
using JigLibX.Utils;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace RPG
{
    public class CGameGUIRenderer
    {

        private Dictionary<string, CGUIWindow> m_Windows;
        private CGameMain m_Game;

        public CGameGUIRenderer(Game _game)
        {
            m_Game = (CGameMain)_game;
            m_Windows = new Dictionary<string, CGUIWindow>();
            m_Windows["selfHealthPoints"] = (new CGUIWindow(Vector2.One * 10, new Vector2(100, 40), Primitives2D.dot));
            CGUILabel hp = new CGUILabel(m_Game.Content.Load<SpriteFont>("debug"), new Vector2(50, 20), "Health: X");
            hp.SetTextAlign(CGUIObject.TextAlign.CENTERED);
            hp.SetLabelColor(Color.Blue);
            m_Windows["selfHealthPoints"].Add(hp);
            m_Windows["selfHealthPoints"].SetWindowMovable(false);
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            if (m_Game.gameState == 2)
            {
                m_Windows["selfHealthPoints"].Draw(spriteBatch);
            }
            spriteBatch.End();
        }

        public void Update(GameTime gameTime)
        {
            if (m_Game.gameState == 2)
            {
                ((CGUILabel)m_Windows["selfHealthPoints"].GUIObjects[0]).SetLabelText(m_Game.Players[m_Game.SelfIndex].Entity.EntityData.CurrentHealthPoints + "/" + m_Game.Players[m_Game.SelfIndex].Entity.EntityData.MaxHealthPoints);
                m_Windows["selfHealthPoints"].Update(gameTime, m_Game.oldMouseState, m_Game.newMouseState);
            }
        }
    }
}
